<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <!--{include file="comm_header.tpl"}-->
</head>
<body ontouchstart style="background: #ebebeb;">
<div class="container" id="container">
    <div class="page">
        <div class="weui-tab">
            <div class="weui-navbar">
                <div class="weui-navbar__item weui-bar__item_on">
                    <span>报价单</span>
                </div>
                <div class="weui-navbar__item">
                    <span>小样订单</span>
                </div>
                <div class="weui-navbar__item">
                    <span>销售订单</span>
                </div>
            </div>
            <div class="weui-tab__panel">
                <!-- 报价单 -->
                <div id="divCost" class="weui-tab__content" style="display: block"></div>
                <!-- 报价单 END -->

                <!-- 小样订单 -->
                <div id="divTemp" class="weui-tab__content"></div>
                <!-- 小样订单 END -->

                <!-- 销售订单 -->
                <div id="divSale" class="weui-tab__content"></div>
                <!-- 销售订单END -->
            </div>
        </div>
    </div>
</div>

<!--{include file="comm_js.tpl"}-->
<script type="text/javascript">
    $(function(){
        var flg = <!--{$flg|default:0}-->
        $('.weui-navbar__item').eq(flg).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');
        $(".weui-tab__content").eq(flg).show().siblings('.weui-tab__content').hide();

        $('.weui-navbar__item').on('click', function () {
            var _this=$(this).index()
            $(this).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');
            $(".weui-tab__content").eq(_this).show().siblings('.weui-tab__content').hide()
        });

        bindCost();
        bindTemp();
        bindSale();
    });

    function costDtl ( code ) {
        location.href = '/wap/orderDtl.html?ajaxFlg=1&code=' + code;
    }
    function tempDtl ( code ) {
        location.href = '/wap/orderDtl.html?ajaxFlg=2&code=' + code;
    }
    function saleDtl ( code ) {
        location.href = '/wap/orderDtl.html?ajaxFlg=3&code=' + code;
    }

    //加载报价单
    function bindCost() {
        E.ajax_post({
            url : "/wap/order.html?ajaxFlg=1",
            call : function (o) {
                if(o.code == 200){
                    var html = '';
                    $.each(o.data, function (i, v) {
                        html += '<div class="weui-form-preview">';
                        html += '   <div class="weui-form-preview__bd">';
                        html += '       <div class="weui-form-preview__item">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">项目名称：</span><span class="text-blue">'+ v['costName'] +'</span></label>';
                        html += '           <span class="weui-form-preview__value"><span class="text-gray">业务员：</span>'+ v['trueName'] +'</span>';
                        html += '       </div>';
                        html += '       <div class="weui-form-preview__item">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">涂装体系：</span>'+ v['categoryName'] +'</label>';
                        html += '           <span class="weui-form-preview__value"></span>';
                        html += '       </div>';
                        html += '       <div class="weui-form-preview__item">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">报价时间：</span>'+ v['createTime'] +'</label>';
                        html += '           <span class="weui-form-preview__value"><span class="text-gray">报价有效期：</span>'+ v['validDate'] +'</span>';
                        html += '       </div>';
                        html += '   </div>';
                        html += '   <div class="weui-form-preview__ft">';
                        html += '       状态 : <span class="text-red">'+ v['statusName'] +'</span>';
                        html += '       <a class="weui-btn weui-btn_plain-default full-right" href="javascript:costDtl(\''+ v['costCode'] +'\')">查看详情</a>';
                        html += '   </div>';
                        html += '</div>';
                    });
                    $("#divCost").html(html);
                }
            }
        });
    }

    //加载小样订单
    function bindTemp() {
        E.ajax_post({
            url : "/wap/order.html?ajaxFlg=2",
            call : function (o) {
                if(o.code == 200){
                    var html = '';
                    $.each(o.data, function (i, v) {
                        html += '<div class="weui-form-preview">';
                        html += '   <div class="weui-form-preview__bd">';
                        html += '       <div class="weui-form-preview__item">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">项目名称：</span><span class="text-blue">'+ v['tempName'] +'</span></label>';
                        html += '           <span class="weui-form-preview__value"><span class="text-gray">要求完成时间：</span>'+ v['requestDate'] +'</span>';
                        html += '       </div>';
                        html += '       <div class="weui-form-preview__item">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">涂装体系：</span>'+ v['categoryName'] +'</label>';
                        html += '           <span class="weui-form-preview__value"></span>';
                        html += '       </div>';
                        html += '       <div class="weui-form-preview__item weui_describe">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">制作内容：<br>及要求&nbsp;</span></label>';
                        html += '           <p>'+ v['request'] +'</p>';
                        html += '       </div>';
                        html += '   </div>';
                        html += '   <div class="weui-form-preview__ft">';
                        html += '       状态 : <span class="text-red">'+ v['statusName'] +'</span>';
                        html += '       <a class="weui-btn weui-btn_plain-default full-right" href="javascript:tempDtl(\''+ v['tempCode'] +'\')">查看详情</a>';
                        html += '   </div>';
                        html += '</div>';
                    });
                    $("#divTemp").html(html);
                }
            }
        });
    }

    //加载销售订单
    function bindSale() {
        E.ajax_post({
            url : "/wap/order.html?ajaxFlg=3",
            call : function (o) {
                console.log(o);
                if(o.code == 200){
                    var html = '';
                    $.each(o.data, function (i, v) {
                        html += '<div class="weui-form-preview">';
                        html += '   <div class="weui-form-preview__bd">';
                        html += '       <div class="weui-form-preview__item">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">项目名称：</span><span class="text-blue">'+ v['saleName'] +'</span></label>';
                        html += '           <span class="weui-form-preview__value"><span class="text-gray">业务员：</span>'+ v['trueName'] +'</span>';
                        html += '       </div>';
                        html += '       <div class="weui-form-preview__item">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">涂装体系：</span>'+ v['categoryName'] +'</label>';
                        html += '           <span class="weui-form-preview__value"></span>';
                        html += '       </div>';
                        html += '      <div class="weui-form-preview__item">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">订单时间：</span>'+ v['createTime'] +'</label>';
                        html += '           <span class="weui-form-preview__value"><span class="text-gray">预计完成日期：</span>'+ v['requestDate'] +'</span>';
                        html += '       </div>';
                        html += '   </div>';
                        html += '   <div class="weui-form-preview__ft">';
                        html += '       状态 : <span class="text-red">'+ v['statusName'] +'</span>';
                        html += '       <a class="weui-btn weui-btn_plain-default full-right" href="javascript:saleDtl(\''+ v['saleCode'] +'\')">查看详情</a>';
                        html += '   </div>';
                        html += '</div>';
                    });
                    $("#divSale").html(html);
                }
            }
        });
    }

</script>
</body>
</html>
